package com.industrial.white.controller;


import com.industrial.common.core.utils.poi.ExcelUtil;
import com.industrial.common.core.web.controller.BaseController;
import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.common.core.web.page.TableDataInfo;
import com.industrial.common.log.annotation.Log;
import com.industrial.common.log.enums.BusinessType;
import com.industrial.white.domain.EmTimeRole;
import com.industrial.white.service.IEmTimeRoleService;
import com.industrial.white.vo.TimeRoleVo;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 时间限制Controller
 * 
 * @author ZHOU_S
 * @date 2023-08-19
 */
@RestController
@RequestMapping("/timeRole")
public class EmTimeRoleController extends BaseController
{
    @Autowired
    private IEmTimeRoleService emTimeRoleService;

    @GetMapping("/getTimeRoleList")
    public TableDataInfo getTimeRoleList(EmTimeRole emTimeRole)
    {
        startPage();
        List<TimeRoleVo> list = emTimeRoleService.getTimeRole(emTimeRole);
        return getDataTable(list);
    }


    /**
     * 查询时间限制列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EmTimeRole emTimeRole)
    {
        startPage();
        List<EmTimeRole> list = emTimeRoleService.selectEmTimeRoleList(emTimeRole);
        return getDataTable(list);
    }

    /**
     * 导出时间限制列表
     */

    @Log(title = "时间限制", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmTimeRole emTimeRole)
    {
        List<EmTimeRole> list = emTimeRoleService.selectEmTimeRoleList(emTimeRole);
        ExcelUtil<EmTimeRole> util = new ExcelUtil<EmTimeRole>(EmTimeRole.class);
        util.exportExcel(response, list, "时间限制数据");
    }

    /**
     * 获取时间限制详细信息
     */
    @GetMapping(value = "/{baseId}")
    public AjaxResult getInfo(@PathVariable("baseId") String baseId)
    {
        return success(emTimeRoleService.selectEmTimeRoleByBaseId(baseId));
    }

    /**
     * 新增时间限制
     */
    @Log(title = "时间限制", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmTimeRole emTimeRole)
    {
        return toAjax(emTimeRoleService.insertEmTimeRole(emTimeRole));
    }

    /**
     * 修改时间限制
     */
    @Log(title = "时间限制", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmTimeRole emTimeRole)
    {
        return toAjax(emTimeRoleService.updateEmTimeRole(emTimeRole));
    }

    /**
     * 删除时间限制
     */
    @Log(title = "时间限制", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baseIds}")
    public AjaxResult remove(@PathVariable String[] baseIds)
    {
        return toAjax(emTimeRoleService.deleteEmTimeRoleByBaseIds(baseIds));
    }


}


